<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title>风味-个人中心</title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link rel="stylesheet" type="text/css" href="css/personCenterPublic.css"/>
		<link rel="stylesheet" type="text/css" href="css/personCenter.css"/>
			<style>
			#add1{width: 80%;position: absolute;top:60%;bottom: 60px; left: 10%; background-color: #000;z-index: 2;opacity: 0.85;display: none;border-radius: 10px;}
			.add1_imgR{width: 22%;position: relative;margin-top:50px; margin-bottom:150px; float: right;margin-right: 7%;}
			.add1_imgL{width: 22%;position: relative;margin-top:50px; float: left;margin-left: 17%;}
			.del{position: relative;float: right;width: 10%;}
		</style>
		<script src="js/jquery-2.1.0.js"></script>
		<script>
			$(function(){
				var str=location.href; //获取本页url地址
				var arr=str.split("?");
				var str1 = arr[1];
				var userIdString = str1.split("=")[1];
				var userId = parseInt(userIdString);
				$.ajax("/fengwei/user/SetNickname",{
					type:"get",
					data:{
						//传送id给后台
						"userId":userId
					},
					success:function(data){
						var html = $('#userNickname');
						console.log(data)
						html.append("昵称："+data)
					},
					error:function(){
						alert(0)
					}
				})
//				控制跳转页面，并将id传下去
				var ownResource = $("#ownResource");
				ownResource.click(function(){
					window.location.href = "personInfo.html?userId="+userId+"";
				})
				var truck = $("#truck")
				truck.click(function(){
					window.location.href = "express.html?userId="+userId+"";
				})
				var help = $("#help")
				help.click(function(){
					window.location.href = "advice.html?userId="+userId+"";
				})

				var about = $("#about")
				about.click(function(){
					window.location.href = "aboutUs.html";
				})
				var seller = $("#seller");
				seller.click(function(){

//					检验是否存在这个userid相对应的sellerid，如果没有---申请成为卖家，如果有，跳转到管理页面

					$.ajax("/fengwei/Seller/test",{
						type:"get",
						data:{
							'userId':userId
						},
					success:function(data){
						
						if(data=="false"){
							window.location.href = "seller.html";
						}else{
							var dataObj = eval('('+data+')');
							var seller = dataObj.sellerId
							window.location.href = "goodsManage.html?sellerId="+seller+"";
							window.location.href = "publish.html?userId="+userId+"";
						}
					}

					})
				})

				var acceptOrder = $("#acceptOrder");
				acceptOrder.click(function(){
					window.location.href = "acceptOrderList.html";
				})

				var releaseOrder = $("#releaseOrder");
				releaseOrder.click(function(){
					window.location.href = "releaseOrderList.html";
				})
			})
		</script>
	</head>
	<body>
		<div id="person_out"><!--个人中心最外层-->
		<div id="headImg"><!--头像部分-->
			<div id="headImg_con">
				<img src="" id="upload" />
				<form action="" method="post" enctype="multipart/form-data" id="form1" target="a">
					<label id="ui_button1" for="file">上传头像</label>
					<input type="file" id="file" name="file"  style="position:absolute;clip:rect(0 0 0 0);">
					<input type="submit" id="ui_button" value="上传头像" style="display: none" onclick="addId()">
				</form>
				<iframe name="a" style="display: none"></iframe>
			</div>
			<p id="userNickname"></p>
		</div>
			<script>
				var file = document.querySelector("#file");
				var ui_button = document.querySelector("#ui_button");
				var ui_button1 = document.querySelector("#ui_button1");
				var upload = document.querySelector("#upload");
				var form1 = document.querySelector('#form1');

				file.onchange = function() {

					if (this != null) {
						ui_button.style.display = "block";
						ui_button1.style.display = "none";
					}
				};

				function addId(){
					form1.action = '/fengwei/file/test?userId='+getUrl()+'';
				}

				function getUrl(){
					var str = location.href;//获取传过来的地址
					var arr = str.split("?");
					var str1 = arr[1];//获取？之后的内容
					userId = str1.split("=")[1];
					return userId;
				}

				$.ajax("/fengwei/file/selectImg",{
					type:"post",
					data:{
						'userId':getUrl()
					},
					success:function(data){
//                        在这里注册成功后跳转页面
						console.log(data);
						var dataObj = eval('('+data+')');
						var arr = dataObj.fileUrl.split("\\");
						var src = arr[arr.length-2]+"/"+arr[arr.length-1];
						setBg(src);
					},
					error:function(){
						alert(0);
					}
				});

				function setBg(src){
					upload.src = src;
				}
			</script>

			<div id="menu_up"><!--菜单上部分-->
			<ul>
				<li id="ownResource">
					<img src="img/personal_Card.png"/>
					<p>个人资料</p>
					<a href="####">></a>
				</li>
				<li id="truck">
					<img src="img/truck.png"/>
					<p>我的快递</p>
					<a href="####">></a>
				</li>
				<li id="acceptOrder">
					<img src="img/dingdan.png"/>
					<p>我的订单</p>
					<a href="####">></a>
				</li>
				<li id="releaseOrder">
					<img src="img/Handshake.png"/>
					<p>我发起的订单</p>
					<a href="####">></a>
				</li>
			</ul>
		</div>
		<div id="menu_down"><!--菜单下部分-->
			<ul>
				<li id = "seller">
					<img src="img/shop.png"/>
					<p>我是卖家</p>
					<a href="####">></a>
				</li>
				<li id = "help">
					<img src="img/helpPic.png"/>
					<p>帮助与反馈</p>
					<a href="####">></a>
				</li>
					<li id="about">
					<img src="img/about_us.png"/>
					<p>关于我们</p>
					<a href="####">></a>
				</li>
			</ul>
		</div>
		<div id="footer"><!--底部-->
			<ul>
				<li id="homeGo"><img src="img/HOME_no.png"/></li>
				<li id="schoolGo"><img src="img/school1.png"/></li>
				<li id="add"> <img src="img/add.png" id="more" onclick="showDivFun()"/></li>
				<li id="shoppingGo"><img src="img/SHOPPING.png"/></li>
				<li id="userGo" class="active"><img src="img/USER-headchoose.png"/></li>
			</ul>
		</div>

			<div id="add1">
				<img class="del" src="img/X.png" onclick="closeDivFun()"/>
				<a href="releaseOrder.html"><img class="add1_imgL" src="img/fadan.png"/></a>
				<a href="acceptOrder.html"><img class="add1_imgR" src="img/jiedan.png"/></a>
			</div>
		</div>	
	</body>
	<!-- 页面跳转--hbl-->
	<script>
		$(function(){
			function getUrl(){
				var str = location.href;//获取传过来的地址
				var arr = str.split("?");
				var str1 = arr[1];//获取？之后的内容
				userId = str1.split("=")[1];
				return userId;
			}
			var homeGo = $("#homeGo");
			var schoolGo = $("#schoolGo");
			var shoppingGo = $("#shoppingGo");
			var userGo = $("#userGo");
		
			homeGo.click(function(){
				window.location.href = "Home.html?userId="+getUrl()+"";
			})
			schoolGo.click(function(){
				window.location.href = "School.html?userId="+getUrl()+"";
			})
			shoppingGo.click(function(){
				window.location.href = "shoppingCart.html?userId="+getUrl()+"";
			})
			userGo.click(function(){
				window.location.href = "personCenter.html?userId="+getUrl()+"";
			})

		})
	</script>
	<script>

		function showDivFun(){
			document.getElementById('add1').style.display='block';
		}
		//关闭事件
		function closeDivFun(){
			document.getElementById('add1').style.display='none';
		}
	</script>
</html>
